package o;

import android.annotation.TargetApi;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.PorterDuff.Mode;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.InsetDrawable;
import android.graphics.drawable.LayerDrawable;
import android.graphics.drawable.RippleDrawable;
import android.os.Build.VERSION;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.d;
import androidx.core.view.ViewCompat;
import com.google.android.material.button.MaterialButton;
import o.aqu.n;

@RestrictTo({d.LIBRARY_GROUP})
public class arh {
    private static final boolean ˏ = (VERSION.SDK_INT >= 21);
    private int ʻ;
    @Nullable
    private Drawable ʻॱ;
    private int ʼ;
    @Nullable
    private GradientDrawable ʼॱ;
    @Nullable
    private Mode ʽ;
    @Nullable
    private GradientDrawable ʿ;
    private boolean ˈ = false;
    private int ˊ;
    private final Paint ˊॱ = new Paint(1);
    private final MaterialButton ˋ;
    private final Rect ˋॱ = new Rect();
    private int ˎ;
    @Nullable
    private ColorStateList ˏॱ;
    @Nullable
    private ColorStateList ͺ;
    private int ॱ;
    private final RectF ॱˊ = new RectF();
    @Nullable
    private Drawable ॱˋ;
    @Nullable
    private GradientDrawable ॱˎ;
    private int ॱॱ;
    @Nullable
    private GradientDrawable ॱᐝ;
    @Nullable
    private ColorStateList ᐝ;
    @Nullable
    private GradientDrawable ᐝॱ;

    public arh(MaterialButton materialButton) {
        this.ˋ = materialButton;
    }

    public void ˏ(TypedArray typedArray) {
        int i = 0;
        this.ˊ = typedArray.getDimensionPixelOffset(n.ʽʻ, 0);
        this.ˎ = typedArray.getDimensionPixelOffset(n.ʿˊ, 0);
        this.ॱ = typedArray.getDimensionPixelOffset(n.ʽʽ, 0);
        this.ʼ = typedArray.getDimensionPixelOffset(n.ʾˋ, 0);
        this.ʻ = typedArray.getDimensionPixelSize(n.ˉᐝ, 0);
        this.ॱॱ = typedArray.getDimensionPixelSize(n.ʿˋ, 0);
        this.ʽ = ash.ˏ(typedArray.getInt(n.ˈᐝ, -1), Mode.SRC_IN);
        this.ᐝ = asi.ˊ(this.ˋ.getContext(), typedArray, n.ˈˋ);
        this.ͺ = asi.ˊ(this.ˋ.getContext(), typedArray, n.ʾᐝ);
        this.ˏॱ = asi.ˊ(this.ˋ.getContext(), typedArray, n.ʾˊ);
        this.ˊॱ.setStyle(Style.STROKE);
        this.ˊॱ.setStrokeWidth((float) this.ॱॱ);
        Paint paint = this.ˊॱ;
        if (this.ͺ != null) {
            i = this.ͺ.getColorForState(this.ˋ.getDrawableState(), 0);
        }
        paint.setColor(i);
        int ʻ = ViewCompat.ʻ(this.ˋ);
        int paddingTop = this.ˋ.getPaddingTop();
        int ᐝ = ViewCompat.ᐝ(this.ˋ);
        int paddingBottom = this.ˋ.getPaddingBottom();
        this.ˋ.ˏ(ˏ ? ʽ() : ˊ());
        ViewCompat.ˏ(this.ˋ, ʻ + this.ˊ, paddingTop + this.ॱ, ᐝ + this.ˎ, paddingBottom + this.ʼ);
    }

    public void ˏ() {
        this.ˈ = true;
        this.ˋ.setSupportBackgroundTintList(this.ᐝ);
        this.ˋ.setSupportBackgroundTintMode(this.ʽ);
    }

    public boolean ॱ() {
        return this.ˈ;
    }

    public void ˋ(@Nullable Canvas canvas) {
        if (canvas != null && this.ͺ != null && this.ॱॱ > 0) {
            this.ˋॱ.set(this.ˋ.getBackground().getBounds());
            this.ॱˊ.set((((float) this.ˋॱ.left) + (((float) this.ॱॱ) / 2.0f)) + ((float) this.ˊ), (((float) this.ˋॱ.top) + (((float) this.ॱॱ) / 2.0f)) + ((float) this.ॱ), (((float) this.ˋॱ.right) - (((float) this.ॱॱ) / 2.0f)) - ((float) this.ˎ), (((float) this.ˋॱ.bottom) - (((float) this.ॱॱ) / 2.0f)) - ((float) this.ʼ));
            float f = ((float) this.ʻ) - (((float) this.ॱॱ) / 2.0f);
            canvas.drawRoundRect(this.ॱˊ, f, f, this.ˊॱ);
        }
    }

    private Drawable ˊ() {
        this.ᐝॱ = new GradientDrawable();
        this.ᐝॱ.setCornerRadius(((float) this.ʻ) + 1.0E-5f);
        this.ᐝॱ.setColor(-1);
        this.ʻॱ = gg.ʻ(this.ᐝॱ);
        gg.ॱ(this.ʻॱ, this.ᐝ);
        if (this.ʽ != null) {
            gg.ˋ(this.ʻॱ, this.ʽ);
        }
        this.ॱˎ = new GradientDrawable();
        this.ॱˎ.setCornerRadius(((float) this.ʻ) + 1.0E-5f);
        this.ॱˎ.setColor(-1);
        this.ॱˋ = gg.ʻ(this.ॱˎ);
        gg.ॱ(this.ॱˋ, this.ˏॱ);
        return ˋ(new LayerDrawable(new Drawable[]{this.ʻॱ, this.ॱˋ}));
    }

    private InsetDrawable ˋ(Drawable drawable) {
        return new InsetDrawable(drawable, this.ˊ, this.ॱ, this.ˎ, this.ʼ);
    }

    public void ˊ(@Nullable ColorStateList colorStateList) {
        if (this.ᐝ != colorStateList) {
            this.ᐝ = colorStateList;
            if (ˏ) {
                ᐝ();
            } else if (this.ʻॱ != null) {
                gg.ॱ(this.ʻॱ, this.ᐝ);
            }
        }
    }

    public ColorStateList ˋ() {
        return this.ᐝ;
    }

    public void ˋ(@Nullable Mode mode) {
        if (this.ʽ != mode) {
            this.ʽ = mode;
            if (ˏ) {
                ᐝ();
            } else if (this.ʻॱ != null && this.ʽ != null) {
                gg.ˋ(this.ʻॱ, this.ʽ);
            }
        }
    }

    public Mode ˎ() {
        return this.ʽ;
    }

    private void ᐝ() {
        if (this.ॱᐝ != null) {
            gg.ॱ(this.ॱᐝ, this.ᐝ);
            if (this.ʽ != null) {
                gg.ˋ(this.ॱᐝ, this.ʽ);
            }
        }
    }

    @TargetApi(21)
    private Drawable ʽ() {
        this.ॱᐝ = new GradientDrawable();
        this.ॱᐝ.setCornerRadius(((float) this.ʻ) + 1.0E-5f);
        this.ॱᐝ.setColor(-1);
        ᐝ();
        this.ʼॱ = new GradientDrawable();
        this.ʼॱ.setCornerRadius(((float) this.ʻ) + 1.0E-5f);
        this.ʼॱ.setColor(0);
        this.ʼॱ.setStroke(this.ॱॱ, this.ͺ);
        InsetDrawable ˋ = ˋ(new LayerDrawable(new Drawable[]{this.ॱᐝ, this.ʼॱ}));
        this.ʿ = new GradientDrawable();
        this.ʿ.setCornerRadius(((float) this.ʻ) + 1.0E-5f);
        this.ʿ.setColor(-1);
        return new arg(asl.ˎ(this.ˏॱ), ˋ, this.ʿ);
    }

    public void ˊ(int i, int i2) {
        if (this.ʿ != null) {
            this.ʿ.setBounds(this.ˊ, this.ॱ, i2 - this.ˎ, i - this.ʼ);
        }
    }

    public void ˏ(int i) {
        if (ˏ && this.ॱᐝ != null) {
            this.ॱᐝ.setColor(i);
        } else if (!ˏ && this.ᐝॱ != null) {
            this.ᐝॱ.setColor(i);
        }
    }

    public void ˋ(@Nullable ColorStateList colorStateList) {
        if (this.ˏॱ != colorStateList) {
            this.ˏॱ = colorStateList;
            if (ˏ && (this.ˋ.getBackground() instanceof RippleDrawable)) {
                ((RippleDrawable) this.ˋ.getBackground()).setColor(colorStateList);
            } else if (!ˏ && this.ॱˋ != null) {
                gg.ॱ(this.ॱˋ, colorStateList);
            }
        }
    }

    public void ॱ(@Nullable ColorStateList colorStateList) {
        int i = 0;
        if (this.ͺ != colorStateList) {
            this.ͺ = colorStateList;
            Paint paint = this.ˊॱ;
            if (colorStateList != null) {
                i = colorStateList.getColorForState(this.ˋ.getDrawableState(), 0);
            }
            paint.setColor(i);
            ʼ();
        }
    }

    public void ˎ(int i) {
        if (this.ॱॱ != i) {
            this.ॱॱ = i;
            this.ˊॱ.setStrokeWidth((float) i);
            ʼ();
        }
    }

    private void ʼ() {
        if (ˏ && this.ʼॱ != null) {
            this.ˋ.ˏ(ʽ());
        } else if (!ˏ) {
            this.ˋ.invalidate();
        }
    }

    public void ˊ(int i) {
        if (this.ʻ != i) {
            this.ʻ = i;
            if (ˏ && this.ॱᐝ != null && this.ʼॱ != null && this.ʿ != null) {
                if (VERSION.SDK_INT == 21) {
                    ॱॱ().setCornerRadius(((float) i) + 1.0E-5f);
                    ʻ().setCornerRadius(((float) i) + 1.0E-5f);
                }
                this.ॱᐝ.setCornerRadius(((float) i) + 1.0E-5f);
                this.ʼॱ.setCornerRadius(((float) i) + 1.0E-5f);
                this.ʿ.setCornerRadius(((float) i) + 1.0E-5f);
            } else if (!ˏ && this.ᐝॱ != null && this.ॱˎ != null) {
                this.ᐝॱ.setCornerRadius(((float) i) + 1.0E-5f);
                this.ॱˎ.setCornerRadius(((float) i) + 1.0E-5f);
                this.ˋ.invalidate();
            }
        }
    }

    @Nullable
    private GradientDrawable ʻ() {
        if (!ˏ || this.ˋ.getBackground() == null) {
            return null;
        }
        return (GradientDrawable) ((LayerDrawable) ((InsetDrawable) ((RippleDrawable) this.ˋ.getBackground()).getDrawable(0)).getDrawable()).getDrawable(1);
    }

    @Nullable
    private GradientDrawable ॱॱ() {
        if (!ˏ || this.ˋ.getBackground() == null) {
            return null;
        }
        return (GradientDrawable) ((LayerDrawable) ((InsetDrawable) ((RippleDrawable) this.ˋ.getBackground()).getDrawable(0)).getDrawable()).getDrawable(0);
    }
}
